package com.hazardousholdings.unkj.validation;

import java.util.ArrayList;
import java.util.List;

public class ValidationResults<T> {

	protected boolean valid;
	protected T result;
	protected List<String> messages;
	
	public ValidationResults(T result, boolean valid) {
		this.result = result;
		this.valid = valid;
		this.messages = new ArrayList<String>(1);
	}
	
	public ValidationResults(T result, boolean valid, String message) {
		this(result, valid);
		this.messages.add(message);
	}
	
	public ValidationResults(T result, boolean valid, List<String> messages) {
		this(result, valid);
		this.messages = new ArrayList<String>(messages);
	}
	
	public boolean isValid() {
		return this.valid;
	}
	
	public T getResult() {
		return this.result;
	}
	
	public String getMessage() {
		if(this.getMessages().size() > 0) {
			return this.getMessages().get(0);
		} else {
			return null;
		}
	}
	
	public List<String> getMessages() {
		return this.messages;
	}
	
}
